package com.shy.merch.controller;

import com.shy.merch.model.OrderQuery;
import com.shy.merch.util.SignUtil;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@Controller
public class OrderController {

    @GetMapping("/create/order")
    public String createOrder(OrderQuery orderQuery, Model model){

        Map<String,String> map = new HashMap<>();
        map.put("userNo","81876509158950842369");
        map.put("appKey","5844c3d51a5d7c8e3a66553051a290d9");
        map.put("payProductCode","cp03");
        map.put("productId",orderQuery.getProductId());
        map.put("productName",orderQuery.getProductName());
        map.put("productNum",orderQuery.getProductNum());
        map.put("payerId","C1256");
        map.put("payerConcat","13912345678");
        map.put("orderMoney",orderQuery.getOrderMoney());
        map.put("pageUrl","http://localhost:8201/show.html");
        map.put("notifyUrl","http://localhost:8201/notice/kq");
        map.put("orderNo",orderQuery.getOrderNo());
        map.put("wayCode",orderQuery.getWayCode());


        String sign = SignUtil.createSign(map, "627637bd50d607230d7447856575f15a");
        map.put("sign",sign);

        model.addAllAttributes(map);

        return "payment";



    }
}


















